<?php
        class setting extends model {
           
           function view(){ 
           
           
          // echo "setting";
             if($this->userdata['oauth'])
             {
             
             $arraynewdata=$this->getuseralldata($this->userdata['oauth'],' ,langid,post,facebookid,sameaddress,shipaddress,shipcountryid,shipproid,shipdisid,shiptumid,shipcode,shipstate,syncfacebook,syncuser,hideemail,hidephone,hidefax,hideetc,emailcontact');
             
             
             if($arraynewdata['userdata']['facebookid']==''){
             
             $data['urlnowset']='/setting';
             
            require pluginpath.'/facebook/facebook.php';

            
            $facebook = new Facebook(array(
            'appId'  =>facebookappid,
            'secret' =>facebooksecret,
            ));
            
            
            $user = $facebook->getUser();
            
            
                if ($user) {
            try {
            // Proceed knowing you have a logged in user who's authenticated.
            $user_profile = $facebook->api('/me');
            } catch (FacebookApiException $e) {
            error_log($e);
            $user = null;
            }
            }

// Login or logout url will be needed depending on current user state.
                if ($user) {
                $logoutUrl = $facebook->getLogoutUrl();
                
                
                $arraynewdata['linkloginfacebook']=baseinfo.'/ajax/checkuserfacebookconnect?noredirect=1&nojson=1&linkto='.$data['urlnowset'];
                
                
                
                } 
                else {
                
                $loginUrl=$facebook->getLoginUrl(
            array(
            'redirect_uri' => baseinfo.'/ajax/checkuserfacebookconnect?noredirect=1&nojson=1&linkto='.$data['urlnowset'],
            'scope' => 'email,user_likes,user_photos,publish_stream,user_about_me,user_videos,status_update,user_birthday,user_location,user_work_history'));
                $arraynewdata['linkloginfacebook']=$loginUrl;
                    
                    }
                    
             }
             
             
             
             
             
             
             
             
             
             
             
             
             
             $arraynewdata['modellist']=$this->getmodellist();
             
             $arraynewdata['countryall']=$this->getcountry();
             $arraynewdata['provinceall']=$this->getprovince();
             $arraynewdata['isuserpage']=1;
             $arraynewdata['templatesetting']=1;
             
             $arraynewdata['langall']=$this->getlangall();
             
             
             $arraynewdata['cssdata'][]=baseinfo.'/css/theme1/setting.css';
             
             $this->loadtemplate('setting',$arraynewdata); 
             
             }else
             {
             
             $arraynewdata=array();
             $this->loadtemplate('error',$arraynewdata);  
             exit;
             
             }
            
          
          
           }
        
        
        }
?>
